<?php

/**
 * This class is for online shop order process.
 * params order step
 * This is the children of controller.
 * PHP5 CMS Typolight
 * Copyright is 34n.sam@gmail.com
 */
 
/**
 * Initialize the system
 */
define('TL_MODE', 'FE');
require('system/initialize.php');


class AjaxCitys extends Controller
{
	/**
	 * This is class construct function.
	 * @params null
	 * @Return null
	 */
	public function __construct()
	{
		parent::__construct();		
	}
	
	/**
	 * Page compile like the index page.
	 * @params null
	 * @Return null
	 */
	public function run()
	{
		$this->import('Database');
		
		$this->getCitysByPid($_POST['id_state']);
	}
	
	/**
	 * Save the new shipping address.
	 * @params null
	 * @Return null
	 */
	private function getCitysByPid($id_state=0)
	{
		if (!$id_state)
			return;
		
		$objCitys = $this->Database->prepare("SELECT * FROM `china_city` WHERE `pid`=? ORDER BY `sortOrder`,`city_en`")
						->execute($id_state);
				
		$strHtml = "";
		while ($objCitys->next())
		{
			$strHtml .= "<option value=\"" . $objCitys->id . "\">" . stripslashes($objCitys->city_en) . "</option>";
		}
		echo $strHtml;exit;
	}
}

if (isset($_POST['citys']) && $_POST['citys'])
{
	$ajaxCitys = new AjaxCitys();
	$ajaxCitys->run();
}
?>